/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package traffic.light.simulator.town.unity;

import java.awt.Color;
import java.awt.Graphics;
import traffic.light.simulator.town.trafficLight.TrafficLight;

/**
 *
 *
 */
public class RoadElement extends TownElement {

    private boolean canGoUp = false;
    private boolean canGoDown = false;
    private boolean canGoRight = false;
    private boolean canGoLeft = false;
    private boolean haveATrafficLight = false;
    private RoadType type;
    private boolean isFree = true;
    private TrafficLight TL;
    
    public RoadElement(int iX, int iY, RoadType type) {
        super(iX, iY, new Color(88, 88, 88));
        this.type = type;
        init();
    }

    private void init() {
        switch (type) {
            case DOWN:
                canGoDown = true;
                break;
            case DOWN_AND_LEFT:
                canGoDown = true;
                canGoLeft = true;
                haveATrafficLight = true;
                break;
            case DOWN_AND_RIGHT:
                canGoDown = true;
                canGoRight = true;
                haveATrafficLight = true;
                break;
            case LEFT:
                canGoLeft = true;
                break;
            case RIGHT:
                canGoRight = true;
                break;
            case UP:
                canGoUp = true;
                break;
            case UP_AND_LEFT:
                canGoUp = true;
                canGoLeft = true;
                haveATrafficLight = true;
                break;
            case UP_AND_RIGHT:
                canGoUp = true;
                canGoRight = true;
                haveATrafficLight = true;
                break;
        }
    }

    public void setFree(boolean isFree) {
        this.isFree = isFree;
    }

    public TrafficLight getTL(){
        return this.TL;
    }
    
    public void setTL(TrafficLight TL) {
        this.TL = TL;
    }
    
    public boolean isFree() {
        return isFree;
    }
    
    public boolean haveATrafficLight() {
        return haveATrafficLight;
    }

    public boolean canGoRight() {
        return canGoRight;
    }

    public boolean canGoLeft() {
        return canGoLeft;
    }

    public boolean canGoUp() {
        return canGoUp;
    }

    public boolean canGoDown() {
        return canGoDown;
    }

    @Override
    public void draw(Graphics g, boolean editionMode) {
        super.draw(g, editionMode);
    }

    @Override
    public void draw(Graphics g) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
